package com.bigflexlib.utils
{
	[Bindable]
	public class LabelDataTuple
	{
		
		public var label:String;
		public var data:*;
		
		public function LabelDataTuple( label:String, data:* )
		{
			this.label = label;
			this.data = data;
		}
		
		/**
		 * 
		 * Label+Data tuples are objects of the kind: { label:String, data:* }
		 * They are used throughout flex
		 * 
		 * @param o
		 * 		The object to test
		 * 
		 * @param strict
		 * 		If set to true it will check ( o is LabelDataTuple ).
		 * 		Otherwise it will just look for a "label" and a "data" property
		 * 
		 * @return 
		 * 
		 */	
		public static function isLabelDataTuple( o:*, strict:Boolean = false ):Boolean
		{
			if ( strict )
				return ( o is LabelDataTuple );
			
			if ( ! ( o is Object ) )
				return false;
			var ps:Array = [];
			for ( var p:String in o )
				ps.push( p );
			ps.sort( );
			return ps.join(",") == "data,label";
		}		
		
	}
}